package com.yx.es.sync;

import com.yx.es.sync.dto.FullDataSyncDTO;
import com.yx.es.sync.property.FullDataSyncProperties;
import com.yx.es.sync.sevice.FullDataSyncService;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author lsx
 * @date 2025/3/3 15:06
 */
@Component
public class TaskRunner implements SmartInitializingSingleton {
    @Resource
    private FullDataSyncService fullDataSyncService;

    @Resource
    private FullDataSyncProperties fullDataSyncProperties;

    @Override
    public void afterSingletonsInstantiated() {
        List<FullDataSyncDTO> taskList = fullDataSyncProperties.getTaskList();
        for (FullDataSyncDTO taskDTO : taskList) {
            fullDataSyncService.syncData(fullDataSyncProperties.getNameServerAddr(), taskDTO);
        }
    }
}

